package org.dtrd.modules.service.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.service.entity.bean.PatientServiceDetail;
import org.dtrd.modules.service.entity.request.PatientServiceRequest;

import java.util.Date;


/**
 * <p>
 *
 * </p>
 *
 * @author QR
 * @since 2022-01-06
 */
@Getter
@Setter
@TableName("dtrd_rl_patient_service_detail")
public class DtrdRlPatientServiceDetail {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    @TableField(value = "relation_id")
    private Integer relationId;

    /**
     * 患者id
     */
    @TableField("patient_id")
    private Integer patientId;

    /**
     * 服务包id
     */
    @TableField("package_id")
    private Integer packageId;

    /**
     * 服务套餐id
     */
    @TableField("service_id")
    private Integer serviceId;

    /**
     * 服务项目名称
     */
    @TableField("service_name")
    private String serviceName;

    /**
     * 执行周期
     */
    @TableField("period")
    private Integer period;

    /**
     * 完成情况, 0-未完成, 1-已完成
     */
    @TableField("status")
    private Integer status;

    /**
     * 服务周期 1-天 2-月 3-年 4-周
     */
    @TableField("period_unit")
    private Integer periodUnit;

    /**
     * 执行人
     */
    @TableField("executor")
    private String executor;

    @TableField("patient_evaluation")
    private Integer patientEvaluation;

    @TableField("patient_evaluation_tag_ids")
    private String patientEvaluationTagIds;

    /**
     * 完成时间
     */
    @TableField("finished_time")
    private Date finishedTime;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    @TableField("create_time")
    private Date createTime;

    @TableField("update_time")
    private Date updateTime;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    public DtrdRlPatientServiceDetail(Integer period, Integer patientId, Integer packageId, Integer serviceId, Integer relationId) {
        this.period = period;
        this.packageId = packageId;
        this.patientId = patientId;
        this.serviceId = serviceId;
        this.relationId = relationId;
    }

    public DtrdRlPatientServiceDetail() {
    }

    public DtrdRlPatientServiceDetail init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdRlPatientServiceDetail parseFromDto(PatientServiceDetail dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        packageId = dto.getPackageId();
        serviceId = dto.getServiceId();
        period = dto.getPeriod();
        status = dto.getStatus();
        executor = dto.getExecutor();
        finishedTime = dto.getFinishedTime();
        remark = dto.getRemark();
        return this;
    }

    public DtrdRlPatientServiceDetail parseFromDto(PatientServiceRequest dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        relationId = dto.getRelationId();
        serviceName = dto.getServiceName();
        period = dto.getPeriod();
        status = dto.getStatus();
        periodUnit = dto.getPeriodUnit();
        return this;
    }

}
